19. Exercise: Sunshine Database
Create an SQLite database for Sunshine
Now it’s time to apply what we’ve learned on sunshine, we want to create a database to store the latest weather information and display that when we cannot connect to the internet!
In this exercise, you'll create the contract and the DB helper classes defining the database schema.
Exercise Code
Exercise: S07.01-Exercise-DatabaseCreation
In each of the following exercises, you will find the same TODO style comments in the code to help you figure out what needs to be done.
In this first exercise, you are required to create a WeatherContract and a DBHelper that will be used in the later exercises.
Because you won't be able to see any visual changes in the app after you're done, we've created some unit tests for you in the code to run and verify that you've completed the code correctly.
SOLUTION:
- In WeatherContract, create a WeatherEntry class that implements BaseColumns
- Create static Strings for the table name and columns as per the comments
- Create a DB helper and implement with onCreate and onUpgrade